package com.bianguo.android.apushdemo.view.wiget.popupwindow;

import android.app.Activity;
import android.support.v7.widget.CardView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.CycleInterpolator;
import android.view.animation.RotateAnimation;
import android.view.animation.ScaleAnimation;
import android.widget.LinearLayout;

import com.bianguo.android.apushdemo.R;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by Administrator on 2017/8/1.
 */

public class PopupWindowDialog extends BasePopupWindow {

    @BindView(R.id.popup_anim_layout)
    CardView animLayout;
    @BindView(R.id.popup_dismiss_layout)
    LinearLayout dismissLayout;

    public PopupWindowDialog(Activity mContext) {
        super(mContext);
    }

    public PopupWindowDialog(Activity mContext, int w, int h) {
        super(mContext, w, h);
    }

    @Override
    public View getPopupView() {
        return LayoutInflater.from(mContext).inflate(R.layout.popup_dialog_layout, null);
    }

    @Override
    public View getAnimView() {
        return animLayout;
    }

    @Override
    public View getDismissView() {
        return null;
    }

    @Override
    public Animation getShowAnimation() {
//        RotateAnimation shakeAnim = new RotateAnimation(0, 15, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
        ScaleAnimation shakeAnim = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f,
                Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
//        shakeAnim.setInterpolator(new CycleInterpolator(2));
        shakeAnim.setRepeatCount(2);
        shakeAnim.setRepeatMode(Animation.REVERSE);
        shakeAnim.setDuration(500);
        return shakeAnim;
    }

    @OnClick({R.id.popup_dismiss_btn, R.id.popup_sure_btn})
    public void onClickBk(View view) {
        if (onClickBtnListener != null) {
            onClickBtnListener.onClickBtn(view);
        }
    }
}
